package com.bluemoon.model.test.dbImort.visitor.file;

import cn.com.bluemoon.daps.common.toolkit.BmAssetUtils;
import com.bluemoon.model.test.dbImort.visitor.FileType;


import java.util.Arrays;

/**
 * @author Jarod.Kong
 * @date 2021/1/13 12:00
 */
public abstract class BaseResourceFile implements ResourceFile {
    protected String filePath;

    public BaseResourceFile(String filePath) {
        this.filePath = filePath;
        checkFile();
    }

    protected void checkFile() {
        boolean match = Arrays.stream(fileType().getLowerCaseSuffix()).anyMatch(s -> filePath.endsWith(s));
        BmAssetUtils.isTrue(match, "后缀不符合");
    }

    abstract public FileType fileType();

    public String getFilePath() {
        return filePath;
    }
}
